package com.itheima.topic6;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class Mytest {
    @MyAnnotation
    public void test1() {
        System.out.println("=============test1===========");
    }

    public void test2() {
        System.out.println("=============test2===========");
    }


    public void test3() {
        System.out.println("=============test3===========");
    }

    @MyAnnotation
    public void test4() {
        System.out.println("=============test4===========");
    }

    public static void main(String[] args) throws InvocationTargetException, IllegalAccessException {
        //获取对象
        Mytest mytest = new Mytest();
        Class<? extends Mytest> c = mytest.getClass();
        Method[] mythods = c.getDeclaredMethods();
        for (Method mythod : mythods) {
            if (mythod.isAnnotationPresent(MyAnnotation.class)) {
                mythod.invoke(mytest);
            }
        }
    }
}
